home *** CD-ROM | disk | FTP | other *** search
/ Tech Win 1995 November / CD [TECH_B].bin / tech_b / delphi / trial / disk4 / doc.pak / DIALOGS.INT < prev    next >
Encoding:
Text File  |  1995-08-08  |  7.1 KB  |  224 lines

  1. {*******************************************************}
  2. {                                                       }
  3. {       Delphi Visual Component Library                 }
  4. {                                                       }
  5. {       Copyright (c) 1995 Borland International        }
  6. {                                                       }
  7. {*******************************************************}
  8.  
  9. unit Dialogs;
  10.  
  11. {$S-,W-,R-}
  12. {$C PRELOAD}
  13.  
  14. interface
  15.  
  16. uses WinTypes, SysUtils, CommDlg, Messages, Classes, Graphics, Controls,
  17.   Buttons, StdCtrls, ExtCtrls, Forms;
  18.  
  19. type
  20.   TMsgDlgType = (mtWarning, mtError, mtInformation, mtConfirmation, mtCustom);
  21.   TMsgDlgBtn = (mbYes, mbNo, mbOK, mbCancel, mbAbort, mbRetry, mbIgnore,
  22.     mbAll, mbHelp);
  23.   TMsgDlgButtons = set of TMsgDlgBtn;
  24.  
  25. const
  26.   mbYesNoCancel = [mbYes, mbNo, mbCancel];
  27.   mbOKCancel = [mbOK, mbCancel];
  28.   mbAbortRetryIgnore = [mbAbort, mbRetry, mbIgnore];
  29.  
  30. type
  31.   TCommonDialog = class(TComponent)
  32.   protected
  33.     function Message(var Msg: TMessage): Boolean; virtual; {$IFNDEF WIN32} export; {$ENDIF}
  34.   public
  35.     constructor Create(AOwner: TComponent); override;
  36.   published
  37.     property Ctl3D: Boolean default True;
  38.     property HelpContext: THelpContext default 0;
  39.   end;
  40.  
  41.   TOpenOption = (ofReadOnly, ofOverwritePrompt, ofHideReadOnly,
  42.     ofNoChangeDir, ofShowHelp, ofNoValidate, ofAllowMultiSelect,
  43.     ofExtensionDifferent, ofPathMustExist, ofFileMustExist, ofCreatePrompt,
  44.     ofShareAware, ofNoReadOnlyReturn, ofNoTestFileCreate);
  45.   TOpenOptions = set of TOpenOption;
  46.  
  47.   TFileExt = string[3];
  48.  
  49.   TFileEditStyle = (fsEdit, fsComboBox);
  50.  
  51.   TOpenDialog = class;
  52.   TComboButton = class;
  53.  
  54.   TDlgControl = class(TObject)
  55.   end;
  56.  
  57.   TComboButton = class(TObject)
  58.   end;
  59.  
  60.   TOpenDialog = class(TCommonDialog)
  61.   public
  62.     constructor Create(AOwner: TComponent); override;
  63.     destructor Destroy; override;
  64.     function Execute: Boolean; virtual;
  65.     property Files: TStrings;
  66.   published
  67.     property DefaultExt: TFileExt;
  68.     property FileEditStyle: TFileEditStyle default fsEdit;
  69.     property FileName: TFileName;
  70.     property Filter: string;
  71.     property FilterIndex: Integer default 1;
  72.     property InitialDir: string;
  73.     property HistoryList: TStrings;
  74.     property Options: TOpenOptions default [];
  75.     property Title: string;
  76.   end;
  77.  
  78.   TSaveDialog = class(TOpenDialog)
  79.     function Execute: Boolean; override;
  80.   end;
  81.  
  82.   TColorDialogOption = (cdFullOpen, cdPreventFullOpen, cdShowHelp);
  83.   TColorDialogOptions = set of TColorDialogOption;
  84.  
  85.   const
  86.     MaxCustomColors = 16;
  87.  
  88.   type
  89.  
  90.   TCustomColors = array[0..MaxCustomColors - 1] of LongInt;
  91.  
  92.   TColorDialog = class(TCommonDialog)
  93.   public
  94.     constructor Create(AOwner: TComponent); override;
  95.     destructor Destroy; override;
  96.     function Execute: Boolean;
  97.   published
  98.     property Color: TColor default clBlack;
  99.     property Ctl3D default False;
  100.     property CustomColors: TStrings;
  101.     property Options: TColorDialogOptions default [];
  102.   end;
  103.  
  104.   TFontDialogOption = (fdAnsiOnly, fdTrueTypeOnly, fdEffects, fdFixedPitchOnly,
  105.     fdForceFontExist, fdNoFaceSel, fdNoOEMFonts, fdNoSimulations, fdNoSizeSel,
  106.     fdNoStyleSel,  fdNoVectorFonts, fdShowHelp, fdWysiwyg, fdLimitSize,
  107.     fdScalableOnly);
  108.   TFontDialogOptions = set of TFontDialogOption;
  109.  
  110.   TFontDialogDevice = (fdScreen, fdPrinter, fdBoth);
  111.  
  112.   TFDApplyEvent = procedure(Sender: TObject; Wnd: HWND) of object;
  113.  
  114.   TFontDialog = class(TCommonDialog)
  115.   protected
  116.     procedure Apply(Wnd: HWND); dynamic;
  117.   public
  118.     constructor Create(AOwner: TComponent); override;
  119.     destructor Destroy; override;
  120.     function Execute: Boolean;
  121.   published
  122.     property Font: TFont;
  123.     property Device: TFontDialogDevice default fdScreen;
  124.     property MinFontSize: Integer;
  125.     property MaxFontSize: Integer;
  126.     property Options: TFontDialogOptions default [fdEffects];
  127.     property OnApply: TFDApplyEvent;
  128.   end;
  129.  
  130.   TPrinterSetupDialog = class(TCommonDialog)
  131.   public
  132.     procedure Execute;
  133.   end;
  134.  
  135.   TPrintRange = (prAllPages, prSelection, prPageNums);
  136.   TPrintDialogOption = (poPrintToFile, poPageNums, poSelection, poWarning,
  137.     poHelp, poDisablePrintToFile);
  138.   TPrintDialogOptions = set of TPrintDialogOption;
  139.  
  140.   TPrintDialog = class(TPrinterSetupDialog)
  141.   public
  142.     function Execute: Boolean;
  143.   published
  144.     property Collate: Boolean default False;
  145.     property Copies: Integer default 0;
  146.     property FromPage: Integer default 0;
  147.     property MinPage: Integer default 0;
  148.     property MaxPage: Integer default 0;
  149.     property Options: TPrintDialogOptions default [];
  150.     property PrintToFile: Boolean default False;
  151.     property PrintRange: TPrintRange default prAllPages;
  152.     property ToPage: Integer default 0;
  153.   end;
  154.  
  155.   TFindOption = (frDown, frFindNext, frHideMatchCase, frHideWholeWord,
  156.     frHideUpDown, frMatchCase, frDisableMatchCase, frDisableUpDown,
  157.     frDisableWholeWord, frReplace, frReplaceAll, frWholeWord, frShowHelp);
  158.   TFindOptions = set of TFindOption;
  159.  
  160.   TFindDialog = class(TCommonDialog)
  161.   protected
  162.     procedure ConvertFields; virtual;
  163.     procedure ConvertFieldsForCallBack; virtual;
  164.     function GetLeft: Integer;
  165.     function GetTop: Integer;
  166.     procedure SetLeft(Value: Integer);
  167.     procedure SetTop(Value: Integer);
  168.     function GetPosition: TPoint;
  169.     procedure SetPosition(const Point: TPoint);
  170.     function Message(var Msg: TMessage): Boolean; override;
  171.     procedure Find; dynamic;
  172.   public
  173.     constructor Create(AOwner: TComponent); override;
  174.     destructor Destroy; override;
  175.     function Execute: Boolean; virtual;
  176.     procedure CloseDialog;
  177.     property Position: TPoint;
  178.     property Handle: HWnd;
  179.     property Left: Integer default -1;
  180.     property Top: Integer default -1;
  181.   published
  182.     property FindText: string;
  183.     property Options: TFindOptions default [frDown];
  184.     property OnFind: TNotifyEvent;
  185.   end;
  186.  
  187.   TReplaceDialog = class(TFindDialog)
  188.   protected
  189.     procedure ConvertFields; override;
  190.     procedure ConvertFieldsForCallBack; override;
  191.     procedure Replace; dynamic;
  192.   public
  193.     destructor Destroy; override;
  194.     function Execute: Boolean; override;
  195.     function Message(var Msg: TMessage): Boolean; override;
  196.   published
  197.     property ReplaceText: string;
  198.     property OnReplace: TNotifyEvent;
  199.   end;
  200.  
  201. function MessageDlg(const Msg: string; AType: TMsgDlgType;
  202.   AButtons: TMsgDlgButtons; HelpCtx: Longint): Word;
  203. function MessageDlgPos(const Msg: string; AType: TMsgDlgType;
  204.   AButtons: TMsgDlgButtons; HelpCtx: Longint; X, Y: Integer): Word;
  205.  
  206. function InputBox(const ACaption, APrompt, ADefault: string): string;
  207. function InputQuery(const ACaption, APrompt: string;
  208.   var Value: string): Boolean;
  209.  
  210. procedure ShowMessage(const Msg: string);
  211. procedure ShowMessagePos(const Msg: string; X, Y: Integer);
  212.  
  213. function CreateMessageDialog(const Msg: string; AType: TMsgDlgType;
  214.   AButtons: TMsgDlgButtons): TForm;
  215.  
  216. const
  217.   MsgDlgMinWidth = 150;
  218.   MsgDlgMinHeight = 55;
  219.   MsgDlgButtonStyle: TButtonStyle = bsAutoDetect;
  220.   MsgDlgGlyphs: Boolean = True;
  221.   MsgDlgBtnSize: TPoint = (X: 77; Y: 27);
  222.  
  223. implementation
  224.